@extends('admin.main')

@section('body')
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>水票明细</h2>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th class="">用户ID</th>
                <th class="">用户姓名</th>
                <th class="">商品名称</th>
                <th class="">消费类型</th>
                <th class="">总数量</th>
                <th class="">购买数量</th>
                <th class="">赠送数量</th>
                <th class="">订单金额 (元)</th>
                <th class="">创建时间</th>
            </tr>
            </thead>
            <tbody>
            @if(count($rows['data']))
                @foreach($rows['data'] as $v)
                    <tr>
                        <td><input class="ids" type="checkbox" name="ids[]" value="{{$v['id']}}"/></td>
                        <td>{{$_GET['id']}}</td>
                        <td>{{$_GET['name']}}</td>
                        <td>{{$v['goods_name']}}</td>
                        <td style="@if($v['use_type']) color:blue; @else color:red;@endif">{{$v['description']}}</td>
                        <td>{{$v['num']}}</td>
                        <td>{{$v['buy_num']}}</td>
                        <td>{{$v['gift_num']}}</td>
                        <td>{{$v['order_amount']}}</td>
                        <td><span>{{$v['created_at']}}</span></td>
                    </tr>
                @endforeach
            @else
                <td colspan="12" class="text-center"> aOh! 暂时还没有内容!</td>
            @endif
            </tbody>
        </table>
    </div>
    <div class="page">
        @if($rows['last_page']>1)
            <div>
                <a class="first" href="{{urlPlat('single','getBillRecord',['page'=>1,'id'=>$_GET['id'],'name'=>$_GET['name']])}}">首页</a>
                @if($rows['prev_page_url'])
                    <a class="prev" href="{{$rows['prev_page_url']}}&id={{$_GET['id']}}&name={{$_GET['name']}}">&lt;&lt;</a>
                @endif
                @if(count($rows['pageNoList']))
                    @foreach($rows['pageNoList'] as $v)
                        @if($rows['current_page'] == $v)
                            <span class="current">{{$v}}</span>
                        @else
                            <a class="num" href="{{urlPlat('single','getBillRecord',['page'=>$v,'id'=>$_GET['id'],'name'=>$_GET['name']])}}">{{$v}}</a>
                        @endif
                    @endforeach
                @endif
                @if($rows['next_page_url'])
                    <a class="next" href="{{$rows['next_page_url']}}&id={{$_GET['id']}}&name={{$_GET['name']}}">&gt;&gt;</a>
                @endif
                <a class="last" href="{{urlPlat('single','getBillRecord',['page'=>$rows['last_page'],'id'=>$_GET['id'],'name'=>$_GET['name']])}}">末页</a>
                <span class="rows">共 {{$rows['total']}}条记录</span>
            </div>
        @endif
    </div>
@endsection

@section('script')

    <script type="text/javascript">

        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var shop_id = $("#sch-sort-txt").attr("data");
            var query  = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if(shop_id != ''){
                query = 'shop_id=' + shop_id + "&" + query;
            }
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });

        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down").hover(function(){
            $("#sub-sch-menu").removeClass("hidden");
        },function(){
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
                var shop_id = $(this).attr("value");
                window.location.href = '{{urlPlat('single','getBucketData')}}?shop_id='+shop_id;
            })
        });
    </script>
@endsection
